package com.hfjyz.base.action;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.hfjyz.base.constant.BaseConstant;
import com.opensymphony.xwork2.ActionSupport;

public class ImageAction extends ActionSupport {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 5320635573372878225L;

    private InputStream imageStream = null;

    public InputStream getImageStream() {
        return imageStream;
    }

    public void setImageStream(InputStream imageStream) {
        this.imageStream = imageStream;
    }

    public String execute() {
        HttpSession session = ServletActionContext.getRequest().getSession();
        byte[] bytes = (byte[]) session.getAttribute(BaseConstant.SESSION_USER_PHOTO);

        imageStream = new ByteArrayInputStream(bytes, 0, bytes.length);
        return SUCCESS;
    }
}
